using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace nDeveloper.UI.Windows.IDE
{
    public class TemplateExecute
    {
        private frmMain _formprincipal;

        public TemplateExecute(frmMain FormPrincipal)
        {
            _formprincipal = FormPrincipal;
        }

        public void ExecuteTemplate(string TemplateFile)
        {
            Process proc = new Process();
            proc.StartInfo.FileName = "cscs.exe";
            proc.StartInfo.Arguments = "/nl /l /noconfig " + "\"" + TemplateFile + "\"";
            proc.StartInfo.Arguments = "\"" + TemplateFile + "\"";
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.CreateNoWindow = true;
            proc.Start();
            string line = null;
            while (null != (line = proc.StandardOutput.ReadLine()))
            {
                _formprincipal.ExcreveLinhaSaida(line);
            }
            proc.WaitForExit();
        }
    }
}
